// 云函数入口文件
const db = uniCloud.database();
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const updateRes = await db.collection('opendb-mall-goods').doc(event.id).update({
		price: event.price,
		remain_count: event.remain_count,
		wqx_count: db.command.inc(event.num)
	});
	if (updateRes.updated === 1) {

		return {
			code: 200,
			msg: '库存更新成功'
		};
	} else {
		return {
			code: 404,
			msg: '商品未找到'
		};
	}
};